import {expect, test} from 'bun:test';
import {exampleVideoSamplePositions} from '../create/iso-base-media/example-stts';
import {createCttsBox} from '../create/iso-base-media/trak/mdia/minf/stbl/create-ctts';

const reference = new Uint8Array([
	0, 0, 3, 128, 99, 116, 116, 115, 0, 0, 0, 0, 0, 0, 0, 110, 0, 0, 0, 1, 0, 0,
	23, 112, 0, 0, 0, 1, 0, 0, 58, 152, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0,
	0, 0, 0, 0, 0, 0, 1, 0, 0, 11, 184, 0, 0, 0, 1, 0, 0, 35, 40, 0, 0, 0, 1, 0,
	0, 11, 184, 0, 0, 0, 1, 0, 0, 46, 224, 0, 0, 0, 2, 0, 0, 11, 184, 0, 0, 0, 1,
	0, 0, 35, 40, 0, 0, 0, 1, 0, 0, 11, 184, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0,
	1, 0, 0, 58, 152, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
	1, 0, 0, 11, 184, 0, 0, 0, 1, 0, 0, 46, 224, 0, 0, 0, 2, 0, 0, 11, 184, 0, 0,
	0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 35, 40, 0, 0, 0, 1, 0, 0, 11, 184, 0,
	0, 0, 1, 0, 0, 35, 40, 0, 0, 0, 1, 0, 0, 11, 184, 0, 0, 0, 3, 0, 0, 23, 112,
	0, 0, 0, 1, 0, 0, 35, 40, 0, 0, 0, 1, 0, 0, 11, 184, 0, 0, 0, 1, 0, 0, 58,
	152, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 11,
	184, 0, 0, 0, 1, 0, 0, 58, 152, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0,
	0, 0, 0, 0, 0, 1, 0, 0, 11, 184, 0, 0, 0, 1, 0, 0, 35, 40, 0, 0, 0, 1, 0, 0,
	11, 184, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 35, 40, 0, 0, 0, 1, 0,
	0, 11, 184, 0, 0, 0, 2, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 58, 152, 0, 0, 0, 1,
	0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 11, 184, 0, 0, 0, 1,
	0, 0, 58, 152, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1,
	0, 0, 11, 184, 0, 0, 0, 2, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 46, 224, 0, 0, 0,
	2, 0, 0, 11, 184, 0, 0, 0, 1, 0, 0, 35, 40, 0, 0, 0, 1, 0, 0, 11, 184, 0, 0,
	0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 35, 40, 0, 0, 0, 1, 0, 0, 11, 184, 0,
	0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 46, 224, 0, 0, 0, 2, 0, 0, 11, 184,
	0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 58, 152, 0, 0, 0, 1, 0, 0, 23,
	112, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 11, 184, 0, 0, 0, 1, 0, 0, 58,
	152, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 11,
	184, 0, 0, 0, 1, 0, 0, 58, 152, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0,
	0, 0, 0, 0, 0, 1, 0, 0, 11, 184, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0,
	58, 152, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
	11, 184, 0, 0, 0, 1, 0, 0, 58, 152, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0,
	0, 0, 0, 0, 0, 0, 1, 0, 0, 11, 184, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0,
	0, 35, 40, 0, 0, 0, 1, 0, 0, 11, 184, 0, 0, 0, 2, 0, 0, 23, 112, 0, 0, 0, 1,
	0, 0, 58, 152, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1,
	0, 0, 11, 184, 0, 0, 0, 1, 0, 0, 35, 40, 0, 0, 0, 1, 0, 0, 11, 184, 0, 0, 0,
	1, 0, 0, 23, 112, 0, 0, 0, 1, 0, 0, 58, 152, 0, 0, 0, 1, 0, 0, 23, 112, 0, 0,
	0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 11, 184, 0, 0, 0, 1, 0, 0, 35, 40, 0, 0,
	0, 1, 0, 0, 11, 184, 0, 0, 0, 1, 0, 0, 35, 40, 0, 0, 0, 1, 0, 0, 11, 184, 0,
	0, 0, 1, 0, 0, 46, 224, 0, 0, 0, 2, 0, 0, 11, 184, 0, 0, 0, 1, 0, 0, 35, 40,
	0, 0, 0, 1, 0, 0, 11, 184, 0, 0, 0, 1, 0, 0, 35, 40, 0, 0, 0, 1, 0, 0, 11,
	184, 0, 0, 0, 1, 0, 0, 35, 40, 0, 0, 0, 1, 0, 0, 11, 184, 0, 0, 0, 1, 0, 0,
	35, 40, 0, 0, 0, 1, 0, 0, 11, 184,
]);

test('ctts atom', () => {
	expect(createCttsBox(exampleVideoSamplePositions)).toEqual(reference);
});
